package com.ktgj.service.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ktgj.common.log.annotation.Log;
import com.ktgj.common.log.enums.BusinessType;
import com.ktgj.common.security.annotation.PreAuthorize;
import com.ktgj.service.domain.Additionalservices;
import com.ktgj.service.service.IAdditionalservicesService;
import com.ktgj.common.core.web.controller.BaseController;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.common.core.utils.poi.ExcelUtil;
import com.ktgj.common.core.web.page.TableDataInfo;

/**
 * 值机附加服务Controller
 * 
 * @author ruoyi
 * @date 2021-09-03
 */
@ControllerAdvice
@RestController
@RequestMapping("/additionalservices")
public class AdditionalservicesController extends BaseController
{
    @Autowired
    private IAdditionalservicesService additionalservicesService;

    /**
     * 查询值机附加服务列表
     */
    @PreAuthorize(hasPermi = "service:additionalservices:list")
    @GetMapping("/list")
    public TableDataInfo list(Additionalservices additionalservices)
    {
        startPage();
        List<Additionalservices> list = additionalservicesService.selectAdditionalservicesList(additionalservices);
        return getDataTable(list);
    }

    /**
     * 导出值机附加服务列表
     */
    @PreAuthorize(hasPermi = "service:additionalservices:export")
    @Log(title = "值机附加服务", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Additionalservices additionalservices) throws IOException
    {
        List<Additionalservices> list = additionalservicesService.selectAdditionalservicesList(additionalservices);
        ExcelUtil<Additionalservices> util = new ExcelUtil<Additionalservices>(Additionalservices.class);
        util.exportExcel(response, list, "值机附加服务数据");
    }

    /**
     * 获取值机附加服务详细信息
     */
    @PreAuthorize(hasPermi = "service:additionalservices:query")
    @GetMapping(value = "/{additionalServicesId}")
    public AjaxResult getInfo(@PathVariable("additionalServicesId") Long additionalServicesId)
    {
        return AjaxResult.success(additionalservicesService.selectAdditionalservicesById(additionalServicesId));
    }

    /**
     * 新增值机附加服务*/
    @PreAuthorize(hasPermi = "service:additionalservices:add")
    @Log(title = "值机附加服务", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Additionalservices additionalservices)
    {
        return toAjax(additionalservicesService.insertAdditionalservices(additionalservices));
    }

    /**
     * 修改值机附加服务*/
    @PreAuthorize(hasPermi = "service:additionalservices:edit")
    @Log(title = "值机附加服务", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Additionalservices additionalservices)
    {
        return toAjax(additionalservicesService.updateAdditionalservices(additionalservices));
    }

    /**
     * 删除值机附加服务*/
    @PreAuthorize(hasPermi = "service:additionalservices:remove")
    @Log(title = "值机附加服务", businessType = BusinessType.DELETE)
	@DeleteMapping("/{additionalServicesIds}")
    public AjaxResult remove(@PathVariable Long[] additionalServicesIds)
    {
        return toAjax(additionalservicesService.deleteAdditionalservicesByIds(additionalServicesIds));
    }
}
